#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	string t;
	int n;
	cin >> t >> n;
	string s;

	int ans = 0;
	vector<string> ans_string;

	while (cin >> s) {
		bool flag = 0;
		for (int i = 0; i < s.size(); i++) {
			if (!(t[i] == '*' || t[i] == s[i])) {
				flag = 1;
				break;
			}
		}
		if (!flag) {
			ans++;
			ans_string.push_back(s);
		}
	}
	cout << ans << endl;
	for (auto i : ans_string)
		cout << i << endl;
	return 0;
}
